<head>
{% if user.is_authenticated %}
<script type="text/javascript" src="/files/js/webtoolkit.drag.js"></script>
{% endif %}
</head>
<div style="background-image: url('/files/{{ da_image }}');background-repeat: no-repeat;width: {{da_width}}px; height: {{da_height}}px;">
</div>
{% if not user.is_authenticated %}
<a href="/accounts/login/?next=/view/{{da_id}}/">
{% endif %}
<div id="dragable1" style="position: absolute; left: {{di_x}}px; top: {{di_y}}px;"> <img border=0 src="/files/images/x.png" >{{di}}</div>
{% if not user.is_authenticated %}
</a>
{% endif %}

{% if user.is_authenticated %}
<script type="text/javascript">

function save_location(element, x, y)
{ 
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
  
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) 
                  document.ajax.dyn="Received:"  + xhr.responseText; 
              else 
                 document.ajax.dyn="Error code " + xhr.status;
         }
    }; 

   xhr.open("GET", "/edit/di/{{da_id}}/" + x + "/" + y + "/",  true); 
   xhr.send(null); 
} 

	var dragable1 = DragHandler.attach(document.getElementById('dragable1'));

	dragable1.dragEnd = save_location;


</script>
<a href="/accounts/logout/">logout...</a>
{% endif %}
